#ifndef ASYNCSUBSCRIBE_H
#define ASYNCSUBSCRIBE_H

#include "mqttclient.h"

#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cctype>
#include <chrono>
#include <libmqttcpp/async_client.h>
#include <unistd.h>

#include "asyncsubsctools.h"

#include <QtCore>

Q_DECLARE_METATYPE(std::string)

class AsyncSubscribe : public MqttClient
{
    Q_OBJECT

public:
    AsyncSubscribe(const std::string name  = "Subscription");
    ~AsyncSubscribe();


    bool activate();
    bool deactivate();

    void messageRecieved(const std::string& topic, std::string message);

private:
    mqtt::async_client* m_pClient;
    async_subscribe_tools::action_listener *m_pSubListener;
    async_subscribe_tools::callback* m_pCb;
    mqtt::connect_options m_connOpts;
    mqtt::itoken_ptr m_conntok;

    std::string m_nameSubscribtion;

    bool f_bExit;
signals:
    void dataRecived(QByteArray topic, QByteArray message);

};


#endif // ASYNCSUBSCRIBEMANAGER_H
